<template>
  <tr>
    <th>
      <input type="checkbox" v-model="check" />
    </th>
    <th>{{name}}</th>
    <th>{{price}}</th>
    <th>
      <button @click="minus">-</button>{{num}}<button @click="add">+</button>
    </th>
    <th>{{num*price}}</th>
    <th><button @click="del">删除</button></th>
  </tr>
</template>

<script>
  export default {
    name: 'GoodInfo',
    props: ['name', 'price', 'num', 'ind', 'checked'],
    data() {
      return {
        check: this.checked,
      }
    },
    methods: {
      minus() {
        this.$emit('minus', this.ind)
      },
      add() {
        this.$emit('add', this.ind)
      },
      del() {
        this.$emit('del', this.ind)
      },
    },
    watch: {
      checked: {
        immediate: true,
        depp: true,
        handler() {
          this.check = this.checked
        },
      },
      check: {
        immediate: true,
        depp: true,
        handler() {
          this.$emit('chec', this.check, this.ind)
        },
      },
    },
  }
</script>

<style></style>
